<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<%@ include file="/common/init.jsp"%>
<html>
<head>
<title>澳斯浪廷会员平台</title>
<link href="<c:url value='/resources/css/css.css'/>" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="<c:url value='/resources/js/jquery-1.7.2.min.js'/>"></script>
<script type="text/javascript" src="<c:url value='/resources/js/validate.js'/>"></script>
<script type="text/javascript" src="<c:url value='/resources/js/mask.js'/>"></script>
<script type="text/javascript">
function frontpage(pageNo){
	window.location.href= "${ctx}/epmore.action?pageNo="+pageNo;
}

function nextpage(pageNo){
	window.location.href= "${ctx}/epmore.action?pageNo="+pageNo;
}
//确认收款
function confirmRemit(id){
	if(confirm("您确定买方已经把钱汇入你的账户？如果已经收到汇款，请单击确定按钮，如果没有收到汇款，清点取消按钮，等待对方汇款")){
    	//交易成功   将对应奖金币划入买方账户
        var url = "${ctx}/confirmRemit.action";
        $(document).mask("系统处理中，请稍后......");
    	 $.ajax({
  			type:'POST',
  			url:url,
  			data: "id="+id,
  			dataType:"html",
  			success: function(data){
  				alert($.trim(data));
  				window.location.href="${ctx}/epmore.action";
  			},
  			error: function(data,status,e){
  				alert(e.name);
  			}
  		});
	}
}
//汇款
function onremit(id){
	if(confirm("您确定您已将对应款项汇入到卖方账户？")){
		//提醒卖方 确认收款
		$(document).mask("系统处理中，请稍后......");
        var url = "${ctx}/onRemit.action";
     	 $.ajax({
   			type:'POST',
   			url:url,
   			data: "id="+id,
   			dataType:"html",
   			success: function(data){
   				alert($.trim(data));
   				window.location.href="${ctx}/epmore.action";
   			},
   			error: function(data,status,e){
   				alert(e.name);
   			}
   		});
	}
}

//卖方取消挂出的ep信息
function epcancel(id){
	if(confirm("您确定要取消该ep交易吗?")){
		//取消ep交易
		$(document).mask("系统处理中，请稍后......");
		$.ajax({
			type: 'POST',
			url: '${ctx}/epcancel.action',
			data: 'id='+id,
			dataType:'html',
			success:function(data){
				alert($.trim(data));
   				window.location.href="${ctx}/epmore.action";
			},
			error:function(data, status, e){
				
			}
		});
	}
}

</script>
</head>
<body leftmargin="0">
<div class="main">
<div class="width_l">
    <iframe src="menu.action" frameborder="0" width="250" height="100%" class="menu"></iframe>
</div>    
    <div class="right">
    <div class="width_r">
        <div class="menu_r">
            <ul>
                <li><a href="index.action">首页</a></li>
                <li><a href="information.action">消息</a></li>
                <li><a href="notice.action">公告中心</a></li>
                <li><a href="news.action">新闻中心</a></li>
                <li><a href="inbox.action">收件箱</a></li>
                <li><a href="tomail.action">写邮件</a></li>
                <li><a href="sent.action">已发送</a></li>
                <li><a href="${ctx}/exit.action">安全退出</a></li> 
            </ul>
        </div>
        <div class="news_top"><img src="<c:url value='/resources/images/top.jpg'/>" /></div>
        <div class="news">
          <h5>EP交易明细</h5><form></form>
          <div class="vvbt">
          <table width="840" border="0" align="center" cellpadding="0" cellspacing="0">
			  <tr>
			    <td width="90" class="vvd">用户ID</td>
			    <td width="50" class="vvd">类型</td>
			    <td width="95" class="vvd">对方ID</td>
			    <!-- <td width="90" class="vvd">交易金额</td> -->
			    <td width="80" class="vvd">需汇款金额</td>
			    <td width="140" class="vvd">添加时间</td>
			    <td width="140" class="vvd">确认时间</td>
			    <td width="60" class="vvd">状态</td>
			    <td width="50" class="vvd">查看</td>
			    <td width="60" class="vvd">操作</td>
			    <td width="50" class="vvd">投诉</td>
			  </tr>
			</table></div>
			<table width="840" border="1" align="center" cellpadding="0" cellspacing="0">
				<c:forEach var="ep" items="${epList}">
					<tr>
					    <td width="90" class="vv">${ep['user_id']}</td>
					    <td width="50" class="vv">${ep['tradetype']}</td>
					    <td width="95" class="vv">${ep['relation_id']}</td>
					    <%-- <td width="90" class="vv">${ep['aomount']}</td> --%>
					    <td width="80" class="vv">${ep['deal_amount']}</td>
					    <td width="140" class="vv">
					    	<fmt:formatDate value="${ep['create_date']}" pattern="yyyy-M-dd HH:mm:ss" />
					    </td>
					    <td width="140" class="vv">
					    	<fmt:formatDate value="${ep['success_date']}" pattern="yyyy-M-dd HH:mm:ss" />
					    </td>
					    <td width="60" class="vv">
					    	<c:forEach var="stat" items="${epStatusList}">
					    		<c:if test="${stat.code eq ep['status']}">${stat.name}</c:if>
					    	</c:forEach>
					   </td>
					   <td width="50" class="vv">
						   <c:choose>
						   		<c:when test="${ep['tradetype'] eq '买入' && ep['status'] eq '2' && ep['type'] eq '1'}">
							   		<a href="epbank.action?account=${ep['relation_id']}&id=${ep['id']}" target="_blank">查看</a>
						   		</c:when>
						   		<c:otherwise>---</c:otherwise>
						   </c:choose>
					   </td>
					    <td width="60" class="vv">
					    	<c:if test="${(ep['tradetype'] eq '卖出') && ep['status'] eq '2' && ep['type'] eq '1'}">
					    		等待汇款<!-- <a>提醒汇款</a> -->
					    	</c:if>
					    	<c:if test="${(ep['tradetype'] eq '卖出') && ep['status'] eq '2' && ep['type'] eq '2'}">
					    		<a href="javascript:void(0);" onclick="confirmRemit('${ep['id']}')">确认收款</a>
					    	</c:if>
					    	<c:if test="${(ep['tradetype'] eq '买入') && ep['status'] eq '2' && ep['type'] eq '1'}">
					    		<a href="javascript:void(0);" onclick="onremit('${ep["id"]}');">汇款</a>
					    	</c:if>
					    	<c:if test="${(ep['tradetype'] eq '买入') && ep['status'] eq '2' && ep['type'] eq '2'}">
					    		等待确认收款<!-- <a>提醒确认</a> -->
					    	</c:if>
					    	<c:if test="${ep['status'] eq '3'}">交易完成</c:if>
					    	<c:if test="${ep['status'] eq '1'}">
					    		<a href="javascript:void(0);" onclick="epcancel('${ep["id"]}');">取消</a>
					    	</c:if>
					    </td>
					    <td width="50" class="vv">
					    	<c:choose>
					    		<c:when test="${ep['status'] eq '2' or ep['status'] eq '3'}">
					    			<a href="tocomplain.action?id=${ep['id']}">投诉<c:if test="${ep['complain_status'] eq '2'}">已处理</c:if></a>
					    		</c:when>
					    		<c:otherwise>
					    			---
					    		</c:otherwise>
					    	</c:choose>
					    </td>
					</tr>
				</c:forEach>
			  	<tr>
		<td style="text-align:right;width: 840px;" colspan="10">
		<c:choose>
			<c:when test="${pageNo >1}">
				<a href="javascript:void(0);" style="text-decoration: none;">
					<span onclick="frontpage(1)">首页</span>
				</a>&nbsp;
				<a href="javascript:void(0);" style="text-decoration: none;">
					<span onclick="frontpage(${pageNo-1})">上一页</span>
				</a>&nbsp;
			</c:when>
			<c:otherwise>
				首页&nbsp;上一页 &nbsp;
			</c:otherwise>
		</c:choose>
		<c:choose>
			<c:when test="${totalPage > pageNo}">	
				<a href="javascript:void(0);" style="text-decoration: none;">
					<span onclick="nextpage(${pageNo+1})">下一页</span> 
				</a>&nbsp;
				<a href="javascript:void(0);" style="text-decoration: none;">
					<span onclick="nextpage(${totalPage})">末页</span> 
				</a>&nbsp;
			</c:when>
			<c:otherwise>
				下一页&nbsp;末页&nbsp;
			</c:otherwise>
		</c:choose>
		</td>
	</tr>
			</table>
        </div> 
        <div class="news_down"><img src="<c:url value='/resources/images/down.jpg'/>" /></div>
    </div>
    </div>
</div>
</body>
</html>
